<!doctype html>
<html lang="en-US">
  <head>
    <title>Web Chat: Activity grouping</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <!--
      For simplicity and code clarity, we are using Babel and React from unpkg.com.
    -->
    <script crossorigin="anonymous" src="https://unpkg.com/core-js@2/client/core.min.js"></script>
    <script crossorigin="anonymous" src="https://unpkg.com/regenerator-runtime@0.13.3/runtime.js"></script>
    <script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone@7.8.7/babel.min.js"></script>
    <script crossorigin="anonymous" src="https://unpkg.com/react@16.8.6/umd/react.development.js"></script>
    <script crossorigin="anonymous" src="https://unpkg.com/react-dom@16.8.6/umd/react-dom.development.js"></script>
    <script crossorigin="anonymous" src="https://unpkg.com/classnames@2.2.6"></script>
    <!--
      This CDN points to the latest official release of Web Chat. If you need to test against Web Chat's latest bits, please refer to pointing to Web Chat's MyGet feed:
      https://github.com/microsoft/BotFramework-WebChat#how-to-test-with-web-chats-latest-bits
    -->
    <script
      crossorigin="anonymous"
      src="https://cdn.botframework.com/botframework-webchat/latest/webchat-es5.js"
    ></script>
    <style>
      html,
      body {
        height: 100%;
      }

      body {
        background-color: #fafafa;
        margin: 0;
      }

      #webchat {
        height: 100%;
        margin: 0;
        transition-duration: 0.5s;
        transition-property: margin;
      }

      .webchat__chat {
        background-color: white;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
        display: flex;
        flex-direction: column;
        height: 100%;
        margin: auto;
        max-width: 360px;
        min-width: 360px;
        transition-duration: 0.5s;
        transition-property: max-width, min-width, width;
      }

      @media (min-width: 720px) {
        #webchat {
          margin: 0 10px;
        }

        .webchat__chat {
          max-width: 480px;
          min-width: 480px;
          width: 480px;
        }
      }
    </style>
  </head>
  <body>
    <div id="webchat"></div>
    <script type="text/babel" data-presets="env,stage-3,react">
      (async function () {
        // Importing from UMD bundle.
        const {
          WebChat: { createDirectLine, renderWebChat }
        } = window;

        // In this demo, we are using Direct Line token from MockBot.
        // Your client code must provide either a secret or a token to talk to your bot.
        // Tokens are more secure. To learn about the differences between secrets and tokens
        // and to understand the risks associated with using secrets, visit https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0

        const res = await fetch(
          'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
          { method: 'POST' }
        );
        const { token } = await res.json();

        renderWebChat(
          {
            className: 'webchat__chat',
            directLine: createDirectLine({ token }),
            styleOptions: {
              botAvatarInitials: 'Bot',
              userAvatarInitials: 'You',

              bubbleBackground: '#F4F4F4',
              bubbleBorderColor: '#F4F4F4',
              bubbleBorderRadius: 4,
              bubbleBorderWidth: 2,
              bubbleNubOffset: 0,
              bubbleNubSize: 10,

              bubbleFromUserBackground: '#F4F4F4',
              bubbleFromUserBorderColor: '#F4F4F4',
              bubbleFromUserBorderRadius: 4,
              bubbleFromUserBorderWidth: 2,
              bubbleFromUserNubOffset: 0,
              bubbleFromUserNubSize: 10,

              groupTimestamp: 3000,
              showAvatarInGroup: 'status'
            }
          },
          document.getElementById('webchat')
        );
      })().catch(err => console.error(err));
    </script>
  </body>
</html>
